package com.ruoyi.system.service.impl;

import java.math.BigDecimal;
import java.util.List;

import cn.hutool.core.date.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ProfitMoneyMapper;
import com.ruoyi.system.domain.ProfitMoney;
import com.ruoyi.system.service.IProfitMoneyService;

/**
 * 财务明细Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-05-24
 */
@Service
public class ProfitMoneyServiceImpl implements IProfitMoneyService 
{
    @Autowired
    private ProfitMoneyMapper profitMoneyMapper;

    /**
     * 查询财务明细
     * 
     * @param id 财务明细主键
     * @return 财务明细
     */
    @Override
    public ProfitMoney selectProfitMoneyById(Integer id)
    {
        return profitMoneyMapper.selectProfitMoneyById(id);
    }

    /**
     * 查询财务明细列表
     * 
     * @param profitMoney 财务明细
     * @return 财务明细
     */
    @Override
    public List<ProfitMoney> selectProfitMoneyList(ProfitMoney profitMoney)
    {
        return profitMoneyMapper.selectProfitMoneyList(profitMoney);
    }

    /**
     * 新增财务明细
     * 
     * @param profitMoney 财务明细
     * @return 结果
     */
    @Override
    public int insertProfitMoney(ProfitMoney profitMoney)
    {
        return profitMoneyMapper.insertProfitMoney(profitMoney);
    }

    /**
     * 修改财务明细
     * 
     * @param profitMoney 财务明细
     * @return 结果
     */
    @Override
    public int updateProfitMoney(ProfitMoney profitMoney)
    {
        return profitMoneyMapper.updateProfitMoney(profitMoney);
    }

    /**
     * 批量删除财务明细
     * 
     * @param ids 需要删除的财务明细主键
     * @return 结果
     */
    @Override
    public int deleteProfitMoneyByIds(Integer[] ids)
    {
        return profitMoneyMapper.deleteProfitMoneyByIds(ids);
    }

    /**
     * 删除财务明细信息
     * 
     * @param id 财务明细主键
     * @return 结果
     */
    @Override
    public int deleteProfitMoneyById(Integer id)
    {
        return profitMoneyMapper.deleteProfitMoneyById(id);
    }

    @Override
    public BigDecimal selectProfitMoneyByIdAndTime(DateTime s, DateTime e, String userId) {
//        List<ProfitMoney> list = profitMoneyMapper.selectProfitMoneyByIdAndTime(s,  e,userId);
        BigDecimal total = new BigDecimal(0);
//        for (ProfitMoney profitMoney : list) {
//           total =  total.add(profitMoney.getChange()) ;
//        }

        return total;
    }
}
